package com.hhh.springai_test.model.enums;

import org.apache.commons.lang3.ObjectUtils;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public enum FileUploadBizEnum {

    USER_AVATAR("用户头像", "user_avatar"),
    POST_IMAGE("文章图片", "article_pic"),
    BOOK_COVER("书籍图片", "book_cover"),

    COMMUNITY_POST_IMAGE("帖子图片", "community_post_pic"),

    READING_ROOM_IMAGE("阅览室图片", "reading_room_image"),

    BANNER_IMAGE("轮播图", "banner_image"),
    COMMUNITY_POST_VIDEO("帖子视频", "community_post_video");



    private final String text;

    private final String value;

    FileUploadBizEnum(String text, String value) {
        this.text = text;
        this.value = value;
    }

    /**
     * 获取值列表
     *
     * @return
     */
    public static List<String> getValues() {
        return Arrays.stream(values()).map(item -> item.value).collect(Collectors.toList());
    }

    /**
     * 根据 value 获取枚举
     *
     * @param value
     * @return
     */
    public static FileUploadBizEnum getEnumByValue(String value) {
        if (ObjectUtils.isEmpty(value)) {
            return null;
        }
        for (FileUploadBizEnum anEnum : FileUploadBizEnum.values()) {
            if (anEnum.value.equals(value)) {
                return anEnum;
            }
        }
        return null;
    }

    public String getValue() {
        return value;
    }

    public String getText() {
        return text;
    }

}
